"use strict";
cc._RF.push(module, '589e1d8lDhC3rDN5tvInanv', 'LevelLianXian_1Item');
// scripts/modes/normalMode/levelLianXian/base/LevelLianXian_1Item.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameEngine_1 = require("../../../../engines/gameEngine");
var MainRoot_1 = require("../../../../Game/MainRoot");
var LevelLianXian_1_1 = require("./LevelLianXian_1");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var NODEROTATION;
(function (NODEROTATION) {
    NODEROTATION[NODEROTATION["LEFT"] = 0] = "LEFT";
    NODEROTATION[NODEROTATION["RIGHT"] = 1] = "RIGHT";
})(NODEROTATION || (NODEROTATION = {}));
var LevelLianXian_1Item = /** @class */ (function (_super) {
    __extends(LevelLianXian_1Item, _super);
    function LevelLianXian_1Item() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        /**当前标签 */
        _this.currentNum = 0;
        /** 对应标签 */
        _this.tagNum = [];
        /** 音频时间 */
        _this.soundTimeLeft = 0;
        /** 毫秒 */
        _this.soundTimeRight = 0;
        _this.nodeRotation = NODEROTATION.LEFT;
        _this.clickIsPlaySound = true;
        _this.oldSoundTime = 0;
        _this.levelNode = null;
        /** level140脚本 */
        _this.level1Script = null;
        /** 是否不能选中 */
        _this.isBuNengSelect = false;
        /**是否在抖动的动画中 */
        _this.isTweenAni = false;
        _this.currentTime = 0;
        _this.startCount = false;
        _this.isStartSoundTime = false;
        _this.startTouchTime = 0;
        /** 触摸屏幕的初始位置 */
        _this.startTouchPos = cc.Vec2.ZERO;
        /** 当前颜色 */
        _this.currentColor = null;
        _this.soundAni = null;
        _this.blackSoundAni = null;
        _this.graySoundAni = null;
        _this.timeLabel = null;
        _this.lb = null;
        _this.currentWayPoint = null;
        _this.currentLianItem = null;
        _this.nowLianNum = -1;
        _this.itemBg = null;
        _this.sigleSound = "";
        return _this;
    }
    LevelLianXian_1Item_1 = LevelLianXian_1Item;
    LevelLianXian_1Item.prototype.onLoad = function () {
        this.blackSoundAni = this.node.getChildByName("soundAni").getComponent(cc.Animation);
        this.graySoundAni = this.node.getChildByName("soundAniGray").getComponent(cc.Animation);
        this.timeLabel = this.node.getChildByName("timeLabel").getComponent(cc.Label);
        this.itemBg = this.node.getChildByName("itemBg");
        this.lb = this.node.getChildByName("lb").getComponent(cc.Label);
        this.soundAni = this.blackSoundAni;
        this.addEvent();
        this.init();
    };
    LevelLianXian_1Item.prototype.changeAniNode = function (isGray) {
        var _this = this;
        this.soundAni = this.graySoundAni;
        var grayActive = this.graySoundAni.node.active;
        var blackActive = this.blackSoundAni.node.active;
        this.graySoundAni.node.active = blackActive;
        this.blackSoundAni.node.active = grayActive;
        if (isGray) {
            this.timeLabel.node.color = cc.Color.GRAY;
            this.lb.node.color = cc.Color.GRAY;
            MainRoot_1.default.LevelSystem.getOneTypeBundle(this.level1Script.getLevelInfo().levelType).load("kuang4", cc.SpriteFrame, function (err, asset) {
                if (err) {
                    console.log(err);
                    return;
                }
                _this.node.getChildByName("bg").getComponent(cc.Sprite).spriteFrame = asset;
            });
        }
        else {
            this.timeLabel.node.color = cc.Color.WHITE;
            this.lb.node.color = cc.Color.BLACK;
            MainRoot_1.default.LevelSystem.getOneTypeBundle(this.level1Script.getLevelInfo().levelType).load("kuang2", cc.SpriteFrame, function (err, asset) {
                if (err) {
                    console.log(err);
                    return;
                }
                _this.node.getChildByName("bg").getComponent(cc.Sprite).spriteFrame = asset;
            });
        }
    };
    LevelLianXian_1Item.prototype.update = function (dt) {
        if (this.isStartSoundTime) {
            this.currentTime -= dt;
            var num = this.currentTime.toFixed(1);
            this.node.getChildByName("timeLabel").getComponent(cc.Label).string = "" + num + "s";
            if (this.currentTime <= 0) {
                this.currentTime = this.oldSoundTime;
                this.isStartSoundTime = false;
                var num1 = this.currentTime.toFixed(1);
                this.node.getChildByName("timeLabel").getComponent(cc.Label).string = "" + num1 + "s";
                this.soundAni.play("soundAniIdle");
                this.level1Script.isPlaySoundNode = null;
                this.level1Script.isPlaySound = false;
            }
        }
    };
    LevelLianXian_1Item.prototype.init = function () {
        this.level1Script = this.levelNode.getComponent(LevelLianXian_1_1.default);
        this.currentTime = this.soundTimeLeft + (this.soundTimeRight / 10);
        var soundTimeNum = this.currentTime.toFixed(1);
        this.node.getChildByName("timeLabel").getComponent(cc.Label).string = "" + soundTimeNum + "s";
        this.oldSoundTime = this.currentTime;
    };
    LevelLianXian_1Item.prototype.stopSoundAni = function () {
        if (this.level1Script.isPlaySoundNode)
            this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).soundAni.play("soundAniIdle");
        this.isStartSoundTime = false;
    };
    LevelLianXian_1Item.prototype.addEvent = function () {
        this.node.on(cc.Node.EventType.TOUCH_START, this.moveComponentStart, this);
        this.node.on(cc.Node.EventType.TOUCH_MOVE, this.moveComponentMove, this);
        this.node.on(cc.Node.EventType.TOUCH_END, this.moveComponentEnd, this);
        this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.moveComponentCancel, this);
    };
    LevelLianXian_1Item.prototype.removeEvent = function () {
        this.node.off(cc.Node.EventType.TOUCH_START, this.moveComponentStart, this);
        this.node.off(cc.Node.EventType.TOUCH_MOVE, this.moveComponentMove, this);
        this.node.off(cc.Node.EventType.TOUCH_END, this.moveComponentEnd, this);
        this.node.off(cc.Node.EventType.TOUCH_CANCEL, this.moveComponentCancel, this);
    };
    /** 播放音频的动画 */
    LevelLianXian_1Item.prototype.playSoundAnimation = function () {
        return __awaiter(this, void 0, void 0, function () {
            var path, num2_1, num2, path;
            var _this = this;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        if (!this.level1Script.sounds[this.currentNum - 1] || this.level1Script.sounds[this.currentNum - 1] == "" || !this.clickIsPlaySound) {
                            return [2 /*return*/];
                        }
                        if (!this.level1Script.itemVaildIsClick && this.isBuNengSelect)
                            return [2 /*return*/];
                        if (!!this.level1Script.isPlaySoundNode) return [3 /*break*/, 2];
                        this.isStartSoundTime = true;
                        path = this.level1Script.levelName + "/" + this.level1Script.sounds[this.currentNum - 1];
                        gameEngine_1.managers().soundMgr.stopAllSound();
                        return [4 /*yield*/, gameEngine_1.managers().soundMgr.playSound(path).then(function (id) {
                                _this.level1Script.soundId = id;
                            })];
                    case 1:
                        _a.sent(); // 播放对应音效
                        this.level1Script.isPlaySoundNode = this.node;
                        this.soundAni.play("soundAniPlay");
                        return [3 /*break*/, 3];
                    case 2:
                        if (this.level1Script.isPlaySoundNode) {
                            gameEngine_1.managers().soundMgr.stopAllSound();
                            if (this.level1Script.isPlaySoundNode.uuid == this.node.uuid) {
                                this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).isStartSoundTime = false;
                                this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).currentTime = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).oldSoundTime;
                                num2_1 = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).currentTime.toFixed(1);
                                this.level1Script.isPlaySoundNode.getChildByName("timeLabel").getComponent(cc.Label).string = "" + num2_1 + "s";
                                this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).soundAni.play("soundAniIdle");
                                this.level1Script.isPlaySoundNode = null;
                                return [2 /*return*/];
                            }
                            this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).isStartSoundTime = false;
                            this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).currentTime = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).oldSoundTime;
                            num2 = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).currentTime.toFixed(1);
                            this.level1Script.isPlaySoundNode.getChildByName("timeLabel").getComponent(cc.Label).string = "" + num2 + "s";
                            this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).soundAni.play("soundAniIdle");
                            this.isStartSoundTime = true;
                            path = this.level1Script.levelName + "/" + this.level1Script.sounds[this.currentNum - 1];
                            gameEngine_1.managers().soundMgr.playSound(path); // 播放对应音效
                            this.level1Script.isPlaySoundNode = this.node;
                            this.soundAni.play("soundAniPlay");
                        }
                        _a.label = 3;
                    case 3: return [2 /*return*/];
                }
            });
        });
    };
    LevelLianXian_1Item.prototype.moveComponentStart = function (touchEvent) {
        if (!this.level1Script.canTouch)
            return;
        this.level1Script.redrawAllPointPath();
        if (!this.level1Script.isPlaySound) {
            // touchEvent.stopPropagation();
            if (!this.level1Script.isStartTime)
                this.level1Script.isStartTime = true;
            // if (this.level1Script.currentSelectNode == null && !this.isBuNengSelect) {
            if (this.level1Script.currentSelectNode == null) {
                if (!this.level1Script.itemVaildIsClick && this.isBuNengSelect) {
                    return;
                }
                this.level1Script.currentSelectNode = this.node;
                this.startTouchPos = touchEvent.getLocation();
                this.currentColors();
            }
        }
        this.node.scale = 1.1;
    };
    LevelLianXian_1Item.prototype.moveComponentMove = function (touchEvent) {
        var _a;
        if (!this.level1Script.canTouch)
            return;
        if (!this.level1Script.isPlaySound) {
            touchEvent.stopPropagation();
            if (this.level1Script.currentSelectNode != null) {
                var touchPos = touchEvent.getLocation();
                var distance = Math.sqrt((touchPos.y - this.startTouchPos.y) * (touchPos.y - this.startTouchPos.y) + (touchPos.x - this.startTouchPos.x) * (touchPos.x - this.startTouchPos.x));
                var nextPos = this.node.parent.convertToNodeSpaceAR(touchPos);
                var pos = this.getNodePos(this.level1Script.currentSelectNode);
                if (!this.currentColor) {
                    this.currentColors();
                }
                if (this.level1Script.cishuNum == 1 && distance >= 10) {
                    this.level1Script.ctx1.strokeColor = this.currentColor;
                    this.level1Script.ctx1.moveTo(pos.x, pos.y);
                    this.level1Script.ctx1.lineTo(nextPos.x, nextPos.y);
                    this.level1Script.ctx1.stroke();
                    this.level1Script.cishuNum++;
                    gameEngine_1.managers().soundMgr.playSound('mainSound/clickWord'); // 点击音效
                }
                else if (this.level1Script.cishuNum != 1 && distance >= 10) {
                    this.level1Script.ctx1.clear();
                    this.level1Script.ctx1.strokeColor = this.currentColor;
                    this.level1Script.ctx1.moveTo(pos.x, pos.y);
                    this.level1Script.ctx1.lineTo(nextPos.x, nextPos.y);
                    this.level1Script.ctx1.stroke();
                    var tag = this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item_1).tagNum;
                    var nodeType = this.nodeRotation;
                    var pNode = null;
                    switch (nodeType) {
                        case NODEROTATION.LEFT: {
                            pNode = this.level1Script.rightNode;
                            break;
                        }
                        case NODEROTATION.RIGHT: {
                            pNode = this.level1Script.leftNode;
                            break;
                        }
                    }
                    var pcNodes = pNode.children;
                    var _loop_1 = function (i) {
                        var cNode = pcNodes[i];
                        var cns = cNode.getComponent(LevelLianXian_1Item_1);
                        var bound = cNode.getBoundingBoxToWorld();
                        // if(bound.contains(touchEvent.getLocation())&&!cns.isBuNengSelect&&!cns.isTweenAni){
                        if (bound.contains(touchEvent.getLocation()) && !cns.isTweenAni && (cNode.getComponent(LevelLianXian_1Item_1).currentNum != this_1.nowLianNum)) {
                            if (cns.isBuNengSelect && !this_1.level1Script.itemVaildIsClick)
                                return "continue";
                            cns.isTweenAni = true;
                            this_1.level1Script.afterSelectNode = cNode;
                            gameEngine_1.managers().soundMgr.playSound('mainSound/clickWord');
                            cNode.scale = 1.1;
                            this_1.level1Script.redrawAllPointPath();
                            // cc.tween(cNode).to(0.1, { scale: 1.1 }).start();
                            this_1.scheduleOnce(function () {
                                cns.isTweenAni = false;
                            }, 0.4);
                            // break;
                        }
                        else if (!bound.contains(touchEvent.getLocation())) {
                            cNode.scale = 1;
                            this_1.level1Script.redrawAllPointPath();
                            cns.isTweenAni = false;
                            if (this_1.level1Script.afterSelectNode && ((_a = this_1.level1Script.afterSelectNode) === null || _a === void 0 ? void 0 : _a.uuid) == cns.node.uuid) {
                                this_1.level1Script.afterSelectNode = null;
                            }
                        }
                    };
                    var this_1 = this;
                    for (var i = 0; i < pcNodes.length; i++) {
                        _loop_1(i);
                    }
                }
            }
        }
        else {
            this.level1Script.ctx1.clear();
        }
    };
    LevelLianXian_1Item.prototype.moveComponentEnd = function (touchEvent) {
        if (!this.level1Script.canTouch)
            return;
        gameEngine_1.default.getManagers().soundMgr.playSound("mainSound/clickWord");
        var bound = this.node.getBoundingBoxToWorld();
        touchEvent.stopPropagation();
        if (!this.level1Script.itemVaildIsClick && this.isBuNengSelect) {
            return;
        }
        // console.log(this.isStartSoundTime,">>>>>>>>怎么回事>>>>>>>>>>")
        if (this.level1Script.currentSelectNode) {
            // 判断是否是同一个类型的节点
            var ns = this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item_1);
            if (ns.nodeRotation == this.nodeRotation) {
                // 切换节点
                this.level1Script.currentSelectNode = this.node;
            }
            else {
                this.level1Script.afterSelectNode = this.node;
                this.moveComponentCancel(touchEvent);
                return;
            }
        }
        if (!this.isStartSoundTime) {
            if (bound.contains(touchEvent.getLocation())) {
                // this.level1Script.stopSound();
                // console.log(">>>>>>>>>>")
                this.playSoundAnimation();
            }
        }
        else {
            this.level1Script.stopSound();
            this.stopSoundAni();
            this.level1Script.isPlaySound = false;
        }
        // if(this.level1Script.currentSelectNode)
        // this.level1Script.currentSelectNode.scale = 1;
        // this.level1Script.redrawAllPointPath();
        // this.level1Script.currentSelectNode = null;
        // this.level1Script.ctx1.clear();
        // this.level1Script.cishuNum = 1;
        // let nodeType= this.nodeRotation;
        // let pNode:cc.Node = null;
        // switch(nodeType){
        //     case NODEROTATION.LEFT:{
        //             pNode = this.level1Script.rightNode;
        //         break;
        //     }
        //     case NODEROTATION.RIGHT:{
        //             pNode = this.level1Script.leftNode;
        //         break;
        //     }
        // }
        // let pcNodes = pNode.children;
        // for(let i=0;i<pcNodes.length;i++){
        //     let cNode = pcNodes[i];
        //     let cns = cNode.getComponent(LevelLianXian_1Item);
        //     cns.isTweenAni = false;
        // }
    };
    LevelLianXian_1Item.prototype.bingoAni = function (tag, index, isLeft) {
        this.level1Script.binGoAni(tag, index, isLeft);
    };
    LevelLianXian_1Item.prototype.moveComponentCancel = function (touchEvent) {
        var _this = this;
        var _a;
        if (!this.level1Script.canTouch)
            return;
        if (!this.level1Script.isPlaySound && this.level1Script.currentSelectNode) {
            // this.level1Script.leftNode.children.forEach((n:cc.Node)=>{
            //     n.scale = 1;
            // });
            // this.level1Script.rightNode.children.forEach((n:cc.Node)=>{
            //     n.scale = 1;
            // });
            this.level1Script.currentSelectNode.scale = 1;
            this.level1Script.redrawAllPointPath();
            var tag = this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item_1).tagNum;
            var currentNum = (_a = this.level1Script.afterSelectNode) === null || _a === void 0 ? void 0 : _a.getComponent(LevelLianXian_1Item_1).currentNum;
            if (this.level1Script.afterSelectNode && tag.includes(currentNum) && this.level1Script.afterSelectNode && (this.level1Script.afterSelectNode.getComponent(LevelLianXian_1Item_1).currentNum != this.nowLianNum || this.currentNum == -1)) {
                this.level1Script.afterSelectNode.scale = 1;
                this.level1Script.redrawAllPointPath();
                this.bingo(this.getNodePos(this.level1Script.currentSelectNode), this.getNodePos(this.level1Script.afterSelectNode), this.currentColor, this.level1Script.afterSelectNode);
                var index = tag.indexOf(currentNum);
                this.bingoAni(currentNum, index);
                this.changeAniNode(true);
                this.level1Script.afterSelectNode.getComponent(LevelLianXian_1Item_1).changeAniNode(true);
                // this.le
                var path = this.level1Script.levelName + "/" + this.level1Script.sounds[currentNum - 1];
                this.level1Script.isAllCheckDone();
                if (this.level1Script.sounds[currentNum - 1] && this.level1Script.sounds[currentNum - 1] != "") {
                    gameEngine_1.managers().soundMgr.playSound(path, function () {
                        _this.level1Script.checkWin();
                    });
                }
                else {
                    if (this.sigleSound == "" || this.sigleSound == null) {
                        this.level1Script.checkWin();
                    }
                }
                if (this.sigleSound != "") {
                    gameEngine_1.managers().soundMgr.stopAllSound();
                    path = this.level1Script.levelName + "/" + this.sigleSound;
                    gameEngine_1.managers().soundMgr.playSound(path, function () {
                        _this.level1Script.checkWin();
                    });
                }
                else {
                    if (this.level1Script.sounds[currentNum - 1] == null || this.level1Script.sounds[currentNum - 1] == "") {
                        this.level1Script.checkWin();
                    }
                }
                if ((this.level1Script.sounds[currentNum - 1] == null || this.level1Script.sounds[currentNum - 1] == "") && (this.level1Script.sounds[currentNum - 1] && this.level1Script.sounds[currentNum - 1] != "")) {
                    this.level1Script.checkWin();
                }
                /** 答对之后，停止音效 */
                if (this.level1Script.isPlaySoundNode) {
                    gameEngine_1.managers().soundMgr.stopAllSound();
                    this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).isStartSoundTime = false;
                    this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).currentTime = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).oldSoundTime;
                    var num2 = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).currentTime.toFixed(1);
                    this.level1Script.isPlaySoundNode.getChildByName("timeLabel").getComponent(cc.Label).string = "" + num2 + "s";
                    this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item_1).soundAni.play("soundAniIdle");
                }
                this.level1Script.isPlaySound = false;
                this.level1Script.isPlaySoundNode = null;
                this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item_1).isBuNengSelect = true;
                this.level1Script.currentSelectNode = null;
                this.level1Script.afterSelectNode.scale = 1;
                this.level1Script.redrawAllPointPath();
                this.level1Script.afterSelectNode = null;
                return;
            }
            else if (this.level1Script.afterSelectNode) {
                this.level1Script.errorSubTime();
                gameEngine_1.managers().soundMgr.playSound('mainSound/error'); // 错误音效
                this.level1Script.currentSelectNode = null;
                this.level1Script.afterSelectNode.scale = 1;
                this.level1Script.redrawAllPointPath();
                this.level1Script.afterSelectNode = null;
                this.level1Script.ctx1.clear();
                this.level1Script.cishuNum = 1;
                return;
            }
            else {
                this.level1Script.currentSelectNode = null;
                this.level1Script.ctx1.clear();
                this.level1Script.cishuNum = 1;
                return;
            }
        }
    };
    LevelLianXian_1Item.prototype.onDestroy = function () {
        this.removeEvent();
    };
    LevelLianXian_1Item.prototype.bingo = function (moveTo, lineTo, colors, otherNode) {
        gameEngine_1.managers().soundMgr.playSound('mainSound/hcy1'); // 答对的音效
        var meCurrentItem = this.currentLianItem;
        if (meCurrentItem) {
            var meotherItem = meCurrentItem.currentLianItem;
            var mecurrentWayPoint = meCurrentItem.currentWayPoint;
            this.currentLianItem = null;
            this.nowLianNum = -1;
            meCurrentItem.nowLianNum = -1;
            meotherItem.currentLianItem = null;
            this.level1Script.removeOnePointPath(mecurrentWayPoint);
            this.currentWayPoint = null;
            meotherItem.currentWayPoint = null;
            this.level1Script.currentYesNum--;
            this.changeAniNode(false);
            meCurrentItem.changeAniNode(false);
            if (meCurrentItem.currentLianItem) {
                var t = meCurrentItem.currentLianItem;
                var meotherItem2 = t.currentLianItem;
                var mecurrentWayPoint2 = t.currentWayPoint;
                meCurrentItem.currentLianItem = null;
                if (meotherItem2 && meotherItem2.nowLianNum) {
                    meotherItem2.nowLianNum = -1;
                }
                t.nowLianNum = -1;
                if (meotherItem2 && meotherItem2.currentLianItem) {
                    meotherItem2.currentLianItem = null;
                }
                this.level1Script.removeOnePointPath(mecurrentWayPoint2);
                t.currentWayPoint = null;
                if (meotherItem2 && meotherItem2.currentWayPoint) {
                    meotherItem2.currentWayPoint = null;
                }
                // this.level1Script.currentYesNum --;
                this.changeAniNode(false);
                t.changeAniNode(false);
            }
        }
        if (otherNode.uuid == this.node.uuid) {
            if (this.node.uuid == this.level1Script.currentSelectNode.uuid) {
                otherNode = this.level1Script.afterSelectNode;
            }
            else {
                otherNode = this.level1Script.currentSelectNode;
            }
        }
        if (otherNode) {
            var os = otherNode.getComponent(LevelLianXian_1Item_1);
            var oCurrentItem = os.currentLianItem;
            if (oCurrentItem) {
                os.nowLianNum = -1;
                oCurrentItem.nowLianNum = -1;
                oCurrentItem.currentLianItem = null;
                os.currentLianItem = null;
                this.level1Script.removeOnePointPath(oCurrentItem.currentWayPoint);
                os.currentWayPoint = null;
                oCurrentItem.currentWayPoint = null;
                this.level1Script.currentYesNum--;
                os.changeAniNode(false);
                oCurrentItem.changeAniNode(false);
            }
        }
        this.level1Script.afterSelectNode.getComponent(LevelLianXian_1Item_1).isBuNengSelect = true;
        this.level1Script.ctx1.clear();
        // let ctx = this.level1Script.DrawingBoard1.getComponent(cc.Graphics);
        // ctx.strokeColor = colors;
        // ctx.moveTo(moveTo.x, moveTo.y);
        // ctx.lineTo(lineTo.x, lineTo.y);
        // ctx.stroke();
        var oneWayPoint = {
            startNode: this.node,
            endNode: otherNode,
            color: colors
        };
        this.currentWayPoint = oneWayPoint;
        this.level1Script.addOnePointPath(oneWayPoint);
        this.currentLianItem = otherNode.getComponent(LevelLianXian_1Item_1);
        otherNode.getComponent(LevelLianXian_1Item_1).currentLianItem = this;
        otherNode.getComponent(LevelLianXian_1Item_1).currentWayPoint = oneWayPoint;
        this.nowLianNum = otherNode.getComponent(LevelLianXian_1Item_1).currentNum;
        otherNode.getComponent(LevelLianXian_1Item_1).nowLianNum = this.currentNum;
        this.level1Script.redrawAllPointPath();
        this.level1Script.currentYesNum++;
        this.level1Script.cishuNum = 1;
    };
    LevelLianXian_1Item.prototype.getNodePos = function (node) {
        var ns = node.getComponent(LevelLianXian_1Item_1);
        switch (ns.nodeRotation) {
            case NODEROTATION.LEFT: {
                var bg = node.getChildByName("bg");
                return cc.v2(node.x + bg.width / 2 * node.scale, node.y);
            }
            case NODEROTATION.RIGHT: {
                var bg = node.getChildByName("bg");
                return cc.v2(node.x - bg.width / 2 * node.scale, node.y);
                break;
            }
        }
    };
    LevelLianXian_1Item.prototype.currentColors = function () {
        var _a;
        var tagNums = (_a = this.level1Script.currentSelectNode) === null || _a === void 0 ? void 0 : _a.getComponent(LevelLianXian_1Item_1).currentNum;
        this.currentColor = cc.color(195, 215, 242);
        while (tagNums) {
            if (tagNums == 1) {
                this.currentColor = cc.color(195, 215, 242);
                return;
            }
            if (tagNums == 2) {
                this.currentColor = cc.color(246, 207, 128);
                return;
            }
            if (tagNums == 3) {
                this.currentColor = cc.color(223, 221, 108);
                return;
            }
            if (tagNums == 4) {
                this.currentColor = cc.color(248, 134, 170);
                return;
            }
            if (tagNums == 5) {
                this.currentColor = cc.color(253, 140, 100);
                return;
            }
            if (tagNums == 6) {
                this.currentColor = cc.color(154, 219, 197);
                return;
            }
            if (tagNums == 7) {
                this.currentColor = cc.color(86, 203, 249);
                return;
            }
            if (tagNums == 8) {
                this.currentColor = cc.color(211, 89, 126);
                return;
            }
            if (tagNums == 9) {
                this.currentColor = cc.color(147, 183, 177);
                return;
            }
            if (tagNums == 10) {
                this.currentColor = cc.color(119, 140, 207);
                return;
            }
            if (tagNums == 11) {
                this.currentColor = cc.color(67, 26, 9);
                return;
            }
            if (tagNums == 12) {
                this.currentColor = cc.color(195, 215, 242);
                return;
            }
            if (tagNums == 13) {
                this.currentColor = cc.color(246, 207, 128);
                return;
            }
            if (tagNums == 14) {
                this.currentColor = cc.color(223, 221, 108);
                return;
            }
            if (tagNums == 15) {
                this.currentColor = cc.color(248, 134, 170);
                return;
            }
            if (tagNums == 16) {
                this.currentColor = cc.color(253, 140, 100);
                return;
            }
            if (tagNums == 17) {
                this.currentColor = cc.color(154, 219, 197);
                return;
            }
            if (tagNums == 18) {
                this.currentColor = cc.color(86, 203, 249);
                return;
            }
            if (tagNums == 19) {
                this.currentColor = cc.color(211, 89, 126);
                return;
            }
            if (tagNums == 20) {
                this.currentColor = cc.color(147, 183, 177);
                return;
            }
            if (tagNums == 21) {
                this.currentColor = cc.color(119, 140, 207);
                return;
            }
            if (tagNums == 22) {
                this.currentColor = cc.color(67, 26, 9);
                return;
            }
            if (tagNums == 23) {
                this.currentColor = cc.color(195, 215, 242);
                return;
            }
            if (tagNums == 24) {
                this.currentColor = cc.color(246, 207, 128);
                return;
            }
            if (tagNums == 25) {
                this.currentColor = cc.color(223, 221, 108);
                return;
            }
            if (tagNums == 26) {
                this.currentColor = cc.color(248, 134, 170);
                return;
            }
        }
    };
    var LevelLianXian_1Item_1;
    __decorate([
        property({ type: cc.Integer, displayName: "当前item标签" })
    ], LevelLianXian_1Item.prototype, "currentNum", void 0);
    __decorate([
        property({ type: cc.Integer, displayName: "对应标签" })
    ], LevelLianXian_1Item.prototype, "tagNum", void 0);
    __decorate([
        property({ type: cc.Integer, displayName: "音频时间/秒" })
    ], LevelLianXian_1Item.prototype, "soundTimeLeft", void 0);
    __decorate([
        property({ type: cc.Integer, displayName: "音频时间/毫秒" })
    ], LevelLianXian_1Item.prototype, "soundTimeRight", void 0);
    __decorate([
        property({ type: cc.Enum(NODEROTATION) })
    ], LevelLianXian_1Item.prototype, "nodeRotation", void 0);
    __decorate([
        property({ displayName: "点击是否播放音效" })
    ], LevelLianXian_1Item.prototype, "clickIsPlaySound", void 0);
    __decorate([
        property({ type: cc.Node, displayName: "关卡脚本" })
    ], LevelLianXian_1Item.prototype, "levelNode", void 0);
    __decorate([
        property()
    ], LevelLianXian_1Item.prototype, "sigleSound", void 0);
    LevelLianXian_1Item = LevelLianXian_1Item_1 = __decorate([
        ccclass
    ], LevelLianXian_1Item);
    return LevelLianXian_1Item;
}(cc.Component));
exports.default = LevelLianXian_1Item;

cc._RF.pop();